<?php

namespace App\Api\Controllers\v1;

use App\Http\Controllers\ApiController;
use App\Http\Response\ApiResponse;
use EasyWeChat\Kernel\Exceptions\HttpException;

/**
 *
 */
class OauthController extends ApiController
{
    /**
     * 用户登陆
     * @OA\Post (
     *     path="/api/v1/auth/login",
     *     summary="查询用户",
     *     tags={"授权管理"},
     *     description="描述",
     *     @OA\Response(response="200", description="An example resource")
     * )
     * @return ApiResponse
     */
    public function login(): ApiResponse
    {
        $params = $this->request->only(['code','userInfo','iv','encryptedData']);
        if ($params){
            try {
                return $this->auth->weChatLogin($params);
            }catch (HttpException $e){
                return $this->response()->error($e->getMessage());
            }
        }
        return $this->response()->error("参数请求错误！");
    }
}
